@import "../../themes/ionic.globals.ios";

// iOS Label
// --------------------------------------------------

/// @prop - Text color of the label by an input, select, or datetime
$label-ios-text-color:                 null !default;

/// @prop - Text color of the stacked/floating label when it is focused
$label-ios-text-color-focused:         null !default;

// deprecated
$label-ios-margin:             null !default;

/// @prop - Margin top of the label
$label-ios-margin-top:         $item-ios-padding-top !default;

/// @prop - Margin end of the label
$label-ios-margin-end:         ($item-ios-padding-end / 2) !default;

/// @prop - Margin bottom of the label
$label-ios-margin-bottom:      $item-ios-padding-bottom !default;

/// @prop - Margin start of the label
$label-ios-margin-start:       0 !default;

// iOS Default Label
// --------------------------------------------------

.label-ios {
  @include deprecated-variable(margin, $label-ios-margin) {
    @include margin($label-ios-margin-top, $label-ios-margin-end, $label-ios-margin-bottom, $label-ios-margin-start);
  }
}


// iOS Default Label Inside An Input/Select Item
// --------------------------------------------------

.item-input .label-ios,
.item-select .label-ios,
.item-datetime .label-ios {
  color: $label-ios-text-color;
}


// iOS Input By Label
// --------------------------------------------------

.label-ios + ion-input .text-input,
.label-ios + ion-textarea .text-input,
.label-ios + .input + .cloned-input {
  @include margin-horizontal($item-ios-padding-start, null);

  width: calc(100% - (#{$item-ios-padding-end} / 2) - #{$item-ios-padding-start});
}


// iOS Stacked & Floating Labels
// --------------------------------------------------

.label-ios[stacked] {
  @include margin(null, null, 4px, null);

  font-size: 1.2rem;
}

.label-ios[floating] {
  @include margin(null, null, 0, null);
  @include transform(translate3d(0, 27px, 0));
  @include transform-origin(start, top);

  transition: transform 150ms ease-in-out;
}

// TODO remove all uses of input-has-focus in v4
// TODO remove all uses of input-has-value in v4
.item-input-has-focus .label-ios[floating],
.input-has-focus .label-ios[floating],
.item-input-has-value .label-ios[floating],
.input-has-value .label-ios[floating] {
  @include transform(translate3d(0, 0, 0), scale(.8));
}

.item-ios.item-label-stacked [item-right], // deprecated
.item-ios.item-label-floating [item-right], // deprecated
.item-ios.item-label-stacked [item-end],
.item-ios.item-label-floating [item-end] {
  @include margin($item-ios-padding-media-top - 2, null, $item-ios-padding-media-bottom - 2, null);
}

.item-input-has-focus .label-ios[stacked],
.input-has-focus .label-ios[stacked],
.item-input-has-focus .label-ios[floating],
.input-has-focus .label-ios[floating] {
  color: $label-ios-text-color-focused;
}


// Generate iOS Label colors
// --------------------------------------------------

@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {

  .label-ios-#{$color-name},
  .item-input .label-ios-#{$color-name},
  .item-select .label-ios-#{$color-name},
  .item-datetime .label-ios-#{$color-name} {
    color: $color-base;
  }

}
